package com.example.demo.controller;

import com.example.demo.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

@RestController
public class TestController {
    @Value("${server.port}")
    private String value;

    @RequestMapping("/read")
    public String readValue() {
        return "value -> " + value;
    }

    @Value("${mystr1}")
    private String mystr1;

    @Value("${mystr2}")
    private String mystr2;

    @Value("${mystr3}")
    private String mystr3;

    @Value("${student.name}")
    private String name;

    @Autowired
    private Student student;

    @PostConstruct
    public void doPostConstruct() {
        System.out.println("------------------------");
        System.out.println(mystr1);
        System.out.println(mystr2);
        System.out.println(mystr3);
        System.out.println(name);
        System.out.println(student);
    }

    @RequestMapping("/say")
    public String sayHi() {
        return "hello";
    }
}
